﻿using DFGK_WMS.IRepository;
using DFGK_WMS.WebAPI.Controllers.Result;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;

namespace DFGJ.WMS_PDA.WebAPI.Controllers.PDA
{
    /// <summary>
    /// PDA
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class PDAController : ControllerBase
    {
        public ITMaterialRepository TMaterialRepository { get; set; }
        public ITCellRepository TCellRepository { get; set; }
        private readonly ISqlSugarClient _Client;

        public PDAController(ITMaterialRepository tMaterialRepository, ITCellRepository tCellRepository)
        {
            TMaterialRepository = tMaterialRepository;
            TCellRepository = tCellRepository;
        }

        /// <summary>
        ///获取物料
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetAllTMateria")]
        public IActionResult GetAllTMateria()
        {
            var list = TMaterialRepository.GetAllMaterialList();
            if (list == null) throw new Exception("数据为空");
            return Ok(new { code = 200, list });
        }

        /// <summary>
        /// 获取全部仓位
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpGet("GetAllTCell")]
        public IActionResult GetAllTCell()
        {
            var list = TCellRepository.GetAllCellList();
            if (list == null) throw new Exception("数据为空");
            return Ok(new { code = 200, list });
        }
    }
}